<?php

namespace App\Admin\Controllers\Goods;

use App\Models\Goods\Product;
use App\Models\Finance\MarketPrice;
use App\Models\Goods\ProductDiscount;
use App\Models\Goods\ProductPower;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;
use Dcat\Admin\Form\NestedForm;
use Illuminate\Support\Facades\DB;
use function PHPUnit\Framework\isEmpty;

class ProductController extends AdminController
{

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Product(), function (Grid $grid) {
            $grid->column('id','ID')->sortable();
            $grid->column('title');
            $grid->column('tt');
            $grid->column('dig_coin');
            $grid->column('pay_period');
            $grid->column('period_of_validity');
            $grid->column('tech_fee');
            $grid->column('price');
            $grid->column('discount_price');
            $grid->column('min_buy_share');
            $grid->column('product_day');
            $grid->column('diya');
            $grid->column('phs_ratio');
            $grid->column("status");
            $grid->column('created_at');
            $grid->fixColumns(2,-2);
            $grid->setActionClass(\Dcat\Admin\Grid\Displayers\DropdownActions::class);
            $grid->model()->orderBy("id",'desc');
            $grid->disableViewButton();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal("id");
                $filter->like('title');
                $filter->equal("tt");
                $filter->equal('dig_coin');
                $filter->equal('status');
                $filter->between("created_at");
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Product(), function (Show $show) {

        });
    }

}
